<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="allmap" style="width:750px;height:500px;margin: auto auto 100px;" ></div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script type="text/javascript">
    var ary = new Array();
    var map = new BMap.Map("allmap");
    map.enableScrollWheelZoom();
    //map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
    map.addControl(new BMap.NavigationControl({
        anchor: BMAP_ANCHOR_TOP_RIGHT
    })); //右上角，仅包含平移和缩放按钮
    //map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_PAN}));  //左下角，仅包含平移按钮
    //map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM}));  //右下角，仅包含缩放按钮
    map.addControl(new BMap.MapTypeControl({
        mapTypes: [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP],
        anchor: BMAP_ANCHOR_TOP_LEFT
    })); //2D图，卫星图
    // 编写自定义函数,创建标注
    function addMarker(point, hname, haddress, hid, telephone, haname, pic, sina_uid, price){
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
        var jsondata = map.getViewport(ary);
        map.centerAndZoom(jsondata.center, jsondata.zoom - 1);
        var sContent = "<h4 style='margin:0 0 5px 0;padding:0.2em 0' title='" + hname + "' alt='" + hname + "'>" + hname + "</h4>" + "<img style='float:right;margin:4px' id='imgDemo" +
        hid + "' src='" + pic +"' width='139' height='104' title='" + hname + "<p style='margin:0;line-height:1.5;font-size:13px;'>" +
        haddress + "</p>" + "</div>";
        var infoWindow = new BMap.InfoWindow(sContent); // 创建信息窗口对象
        if (price) {
            if (telephone && telephone != '-' && telephone != '--') {
                var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;">' + telephone + '</span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;">¥' + price + '<font style="font-size:12px; color:#a79f99;">起</font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
                    offset: new BMap.Size(-55, -95)
                });
            } else {
                var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;"></span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;">¥' + price + '<font style="font-size:12px; color:#a79f99;">起</font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
                    offset: new BMap.Size(-55, -95)
                });
            }
        } else {
            if (telephone && telephone != '-' && telephone != '--') {
                var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;">' + telephone + '</span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;"><font style="font-size:12px; color:#a79f99;"></font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
                    offset: new BMap.Size(-55, -95)
                });
            }else {
                var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;"></span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;"><font style="font-size:12px; color:#a79f99;"></font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
                    offset: new BMap.Size(-55, -95)
                });
            }
        }
        marker.setLabel(label);
        label.setStyle({
            border: "none",
            cursor: "pointer"
        });
        infoWindow.addEventListener("open", function(){
            marker.getLabel().hide();
        });
        infoWindow.addEventListener("close", function(){
            marker.getLabel().show();
        });
        label.addEventListener("click", function(){
            window.open('showhotel.php?hotel_id=' + hid + '&cid=2355674321&uid=2355674321');
        });
        // var markerClusterer = new BMapLib.MarkerClusterer(map, {markers:ary});点聚合  有报错
    }
    
    var point = new BMap.Point(116.434116, 39.963653);
    ary.push(new BMap.Point(116.434116, 39.963653));
    addMarker(point, 'inmyshow大酒店分店-1', '河北省秦皇岛市', '50', '010-15154512-1234', '波尔多北乐湖Camp', '', '1759416613', '0.01');
    var point = new BMap.Point(116.413002, 40.013998);
    ary.push(new BMap.Point(116.413002, 40.013998));
    addMarker(point, '集团新增酒店测试', '', '3509', '010-1234541-111', '集团新增酒店测试', 'http://hotel.ppe.joyinter.net/upload/upload/1366083757.jpg', '0', '');
    
	
//    var baidu = {};
//    baidu = function(){
//        return {
//            show: function(json){
//	            var ary = new Array();
//			    var map = new BMap.Map("allmap");
//			    map.enableScrollWheelZoom();
//			    map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT})); //右上角，仅包含平移和缩放按钮
//			    map.addControl(new BMap.MapTypeControl({
//				    mapTypes: [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP],
//				    anchor: BMAP_ANCHOR_TOP_LEFT
//			    })); //2D图，卫星图
//			    var point = new BMap.Point(116.434116, 39.963653);
//			    ary.push(new BMap.Point(116.434116, 39.963653));
//			    addMarker(point, 'inmyshow大酒店分店-1', '河北省秦皇岛市', '50', '010-15154512-1234', '波尔多北乐湖Camp', '', '1759416613', '0.01');
//			    var point = new BMap.Point(116.413002, 40.013998);
//			    ary.push(new BMap.Point(116.413002, 40.013998));
//			    addMarker(point, '集团新增酒店测试', '', '3509', '010-1234541-111', '集团新增酒店测试', 'http://hotel.ppe.joyinter.net/upload/upload/1366083757.jpg', '0', '');
//            },
//            addMarker: function(point, hname, haddress, hid, telephone, haname, pic, sina_uid, price){
//                var marker = new BMap.Marker(point);
//                map.addOverlay(marker);
//                var jsondata = map.getViewport(ary);
//                map.centerAndZoom(jsondata.center, jsondata.zoom - 1);
//                var sContent = "<h4 style='margin:0 0 5px 0;padding:0.2em 0' title='" + hname + "' alt='" + hname + "'>" + hname + "</h4>" + "<img style='float:right;margin:4px' id='imgDemo" +
//                hid +
//                "' src='" +
//                pic +
//                "' width='139' height='104' title='" +
//                hname +
//                "<p style='margin:0;line-height:1.5;font-size:13px;'>" +
//                haddress +
//                "</p>" +
//                "</div>";
//                var infoWindow = new BMap.InfoWindow(sContent); // 创建信息窗口对象
//                if (price) {
//                    if (telephone && telephone != '-' && telephone != '--') {
//                        var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;">' + telephone + '</span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;">¥' + price + '<font style="font-size:12px; color:#a79f99;">起</font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
//                            offset: new BMap.Size(-55, -95)
//                        });
//                    }
//                    else {
//                        var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;"></span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;">¥' + price + '<font style="font-size:12px; color:#a79f99;">起</font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
//                            offset: new BMap.Size(-55, -95)
//                        });
//                    }
//                }
//                else {
//                    if (telephone && telephone != '-' && telephone != '--') {
//                        var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;">' + telephone + '</span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;"><font style="font-size:12px; color:#a79f99;"></font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
//                            offset: new BMap.Size(-55, -95)
//                        });
//                    }
//                    else {
//                        var label = new BMap.Label('<div style="position:relative; width:115px; height:76px; border:1px solid #dbdbdb; color:#333; padding:5px;"><h4 style="margin:10px 0 5px 0;font-size:12px;font-weight:bold; color:#000;" title="' + hname + '" alt="' + hname + '">' + haname + '</h4>' + '<span style="color:#000;display:block; line-height:24px;"></span>' + '<span style="font-family:微软雅黑;display:block;font-size:16px; font-weight:bold; color:#df151a;"><font style="font-size:12px; color:#a79f99;"></font></span>' + '<span style="position:absolute; width:9px; height:6px; background:url(images/default/tip_blue_arrows.gif) no-repeat -18px 0px; top:85px; left:58px;"></span></div>', {
//                            offset: new BMap.Size(-55, -95)
//                        });
//                    }
//                }
//                marker.setLabel(label);
//                label.setStyle({
//                    border: "none",
//                    cursor: "pointer"
//                });
//                infoWindow.addEventListener("open", function(){
//                    marker.getLabel().hide();
//                });
//                infoWindow.addEventListener("close", function(){
//                    marker.getLabel().show();
//                });
//                label.addEventListener("click", function(){
//                    window.open('showhotel.php?hotel_id=' + hid + '&cid=2355674321&uid=2355674321');
//                });
//                // var markerClusterer = new BMapLib.MarkerClusterer(map, {markers:ary});点聚合  有报错
//            }
//        }
//    }
	
	
</script>

</body>
</html>